package servlet;

import model.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/insert")
public class StulnsertData extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("信息列表");
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");

        PrintWriter writer =resp.getWriter();
        writer.write("<!DOCTYPE html>");
        writer.write("<html>");
        writer.write("<head>");
        writer.write("</head>");
        writer.write("<title>学生信息添加界面</title>");
        writer.write("<body style='background:lightyellow'>");
        writer.write("<h1>学生信息展示页面</h1>");
        writer.write(  "<div style='margin:0 auto;width:600px;border:solid 3px red;'>"+
                "<h3><a href='insert'>录入信息</a></h3>");
        writer.write("<form action='insertok'>"+
                "姓名：<input type='text' name='name'><br>"+
                "性别：<input type='text' name='sex'><br>"+
                "年龄：<input type='text' name='age'><br>"+
                "专业：<input type='text' name='major'><br>"+
                "<button>提交</button>"+
                "<input type='reset' value='重置'/>"+
                "</form>"+
                "</div>");
        writer.write("</body>");
        writer.write("</html>");

     }
}
